﻿using System;
using System.Diagnostics.Contracts;
using Adalbertus.BudgetPlanner.Domain;

namespace Adalbertus.BudgetPlanner.ViewModels.ExternalSources
{
    public class IncomeEntryVM
    {
        private IncomeEntry _wrappedIncomeEntry;
        public IncomeEntry WrappedIncomeEntry
        {
            get
            {
                Contract.Ensures(Contract.Result<IncomeEntry>() != null);
                return _wrappedIncomeEntry;
            }
        }

        public IncomeVM Parent { get; private set; }

        public IncomeEntryVM(IncomeEntry incomeEntry) :
            this(incomeEntry, null)
        { 
        }

        public IncomeEntryVM(IncomeEntry incomeEntry, IncomeVM parent)
        {
            Contract.Requires<ArgumentNullException>(incomeEntry != null);
            Parent = parent;
            _wrappedIncomeEntry = incomeEntry;
        }

        public string Name { get { return WrappedIncomeEntry.Income.Name; } }
        public decimal Value
        {
            get { return WrappedIncomeEntry.Value; }
            set { WrappedIncomeEntry.Value = value; }
        }
        public DateTime Date 
        { 
            get { return WrappedIncomeEntry.Date; }
            set { WrappedIncomeEntry.Date = value; }
        }
    }
}
